﻿<!--#include file="inc/AspCms_SettingClass.asp" -->
<%
dim action : action=getForm("action","get")
if action = "login" then
	dim UserName,Password,sql,code,Rs,atype
	UserName = filterPara(getForm("username","post"))
	atype = getForm("atype","post")
	Password = md5(getForm("Password","post"),16)
	code     = getForm("code","post")
	if admincode=1 then
		if code <> Session("Code") then	alertMsgAndGo "您填写的验证码错误!","-1"
	end if
	if isOutSubmit then  alertMsgAndGo"非法外部提交被禁止","-1"

'	User UserGroup
'	LoginName
'Password
'GroupID
'IsAdmin
	sql = "select count(*) from {prefix}User where LoginName = '"& UserName &"' and Password='"&Password&"'"
	Dim rsObj : Set rsObj=Conn.Exec(sql,"r1")
	if rsObj(0)=1 then
	
		
		Set rsObj=Conn.Exec("select IsAdmin, GroupStatus,GroupName, UserStatus, UserID, GroupMenu,GroupSort, LanguageID,adminrand from {prefix}User as a, {prefix}UserGroup as b where LoginName='"&UserName&"' and a.GroupID=b.GroupID","r1")	
		if not rsObj.Eof Then
			if rsObj("IsAdmin")<>1 then alertMsgAndGo"对不起，你不是管理员！","-1"
			if rsObj("GroupStatus")<>1 then alertMsgAndGo"对不起，您所在用户组已被禁用！","-1"
			if rsObj("UserStatus")<>1 then alertMsgAndGo"对不起，您的账号已被禁用！","-1"
			Session("adminName")=UserName
			Session("GroupName")=rsObj("GroupName")
			'wCookie"adminpwd",getForm("Password","post")
			Session("adminpwd") = getForm("Password","post")
			Session("adminId")=rsObj("UserID")
			Session("groupMenu")=repnull(rsObj("GroupMenu"))
			Session("GroupSort")=repnull(rsObj("GroupSort"))
			'查找
			dim LanguageID
			LanguageID=rsObj("LanguageID")

			if isnul(LanguageID) then 				
				set rs=conn.exec("select LanguageID,LanguagePath,Alias from {prefix}Language where IsDefault=1","exe")
				if rs.eof then					
					echoErr err_15,15,"没有设置默认语言"
				else
					LanguageID=rs(0)
				end if
			else 	
				set rs=conn.exec("select LanguageID,LanguagePath,Alias from {prefix}Language where LanguageID="&LanguageID,"exe")				
				LanguageID=rs(0)	
			end if 
			randomize
			dim randnum
			randnum=clng(rnd*99999999)
			Conn.Exec"update {prefix}User set adminrand='"& randnum &"' where UserID="&rsObj("UserID"),"exe"	
			Session("adminrand")=rsObj("adminrand")	
			Session("languageID")=LanguageID			
			Session("LanguagePath")=rs("LanguagePath")
			Session("LanguageAlias")=rs("Alias")
			

			rs.close : set rs=nothing
			Conn.Exec"update {prefix}User set LastLoginTime='"&now()&"',LastLoginIP='"&getIp()&"',LoginCount=LoginCount+1 where UserID="&rsObj("UserID"),"exe"	
			if atype=0 then		
			response.Redirect("index.asp")
			else
			response.Redirect("index_user.asp")	
			end if
		end if
	else
		alertMsgAndGo "用户名或密码错误!","-1"
	end if
	rsObj.Close() : set rsObj=Nothing	
elseif action = "logout" then
	Session("adminName")=""
	Session("adminId")=""
	Session("groupMenu")=""
	Session("SceneMenu")=""
	response.Redirect("login.asp"):response.End()
elseif action = "relog" then
	alertMsgAndGo "对不起,您的登录状态已经失效,请重新登录!","login.asp"
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>

<title><%=setting.siteTitle%>-企业网站管理系统</title>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT src="http://www.codefans.net/ajaxjs/jquery-1.6.2.min.js"></SCRIPT>
<SCRIPT language=javascript type=text/javascript>
	function killerror()
	{
		return true;	
	}
	window.onerror=killerror;
	$(document).ready(function(){
		$('#username').focus();
		$('#adminlogin').submit(function(){
			if($.trim($('#username').val())=='')
			{
				$('#username').css("border-color","#ff9900");
				$('#username').focus();
				return false;
			}
			else
			{
				$('#username').css("border-color","");
			}

			if($.trim($('#password').val())=='')
			{
				$('#password').css("border-color","#ff9900");
				$('#password').focus();
				return false;
			}
			else
			{
				$('#password').css("border-color","");
			}
			
			if($.trim($('#checkcode').val()).length!=4)
			{
				$('#checkcode').css("border-color","#ff9900");
				$('#checkcode').focus();
				return false;
			}
			else
			{
				$('#checkcode').css("border-color","");
			}
			return true;
		})
	});
</SCRIPT>

<STYLE type=text/css>BODY {
	TEXT-ALIGN: center; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ddeef2; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
}
A:link {
	COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
	COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
	COLOR: #ff0000; TEXT-DECORATION: underline
}
A:active {
	TEXT-DECORATION: none
}
.input {
	BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 20px; WIDTH: 182px; HEIGHT: 20px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid
}
.input1 {
	BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 20px; WIDTH: 120px; HEIGHT: 20px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid
}
</STYLE>

<META name=GENERATOR content="MSHTML 8.00.6001.23486"></HEAD>
<BODY>
		<form method="post" action="?action=login" onsubmit="writeCookie('username',this.username.value, 1)">
            <input type="hidden" name="gotopage" value="/aspcms/index.asp">
            <input type="hidden" name="dopost" value="login">
	 <input name="atype" type="hidden" value="0" />
<DIV></DIV>
<TABLE style="MARGIN: auto; WIDTH: 100%; HEIGHT: 100%" border=0 cellSpacing=0 
cellPadding=0>
  <TBODY>
  <TR>
    <TD height=150>&nbsp;</TD></TR>
  <TR style="HEIGHT: 254px">
    <TD>
      <DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG style="DISPLAY: block" 
      src="images/body_03.jpg"> </DIV>
      <DIV style="BACKGROUND-COLOR: #278296">
      <DIV style="MARGIN: 0px auto; WIDTH: 936px">
      <DIV 
      style="BACKGROUND: url(images/body_05.jpg) no-repeat; HEIGHT: 155px">
      <DIV 
      style="TEXT-ALIGN: left; WIDTH: 265px; FLOAT: right; HEIGHT: 125px; _height: 95px">
      <TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
        <TBODY>
        <TR>
          <TD style="HEIGHT: 43px"><INPUT id=username class=input type=text name=username>
		  </TD>
		</TR>
        <TR>
          <TD><INPUT id=password class=input type=password name=password>
		</TD>
		</TR>	



		
        <TR>
          <TD style="HEIGHT: 50px"><INPUT id=checkcode class=yzm size=8  type=text name=code>
			<img src="../inc/checkcode.asp" id="SeedImg" align="absmiddle" style="cursor:pointer;" border="0" alt="点我刷新" title="点我刷新" onclick="changeimg()" /> </TD></TR></TBODY></TABLE></DIV>
      <DIV style="HEIGHT: 1px; CLEAR: both"></DIV>
      <DIV style="WIDTH: 380px; FLOAT: right; CLEAR: both">
      <TABLE border=0 cellSpacing=0 cellPadding=0 width=300>
        <TBODY>
        <TR>
          <TD width=100 align=right><INPUT 
            style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
            id=btnLogin src="images/btn1.jpg" 
            type=image name=btnLogin></TD>
          <TD width=100 align=middle><INPUT 
            style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
            id=btnReset src="images/btn2.jpg" 
            type=image 
name=btnReset></TD></TR></TBODY></TABLE></DIV></DIV></DIV></DIV>
      <DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG 
      src="images/body_06.jpg"> </DIV></TD></TR>
  <TR style="HEIGHT: 30%">
    <TD>&nbsp;</TD></TR></TBODY></TABLE></FORM></BODY></HTML>
